﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Sgr.Admin.WebHost.Infrastructure.Migrations.Sgr
{
    /// <inheritdoc />
    public partial class SgrSchemaSchema_20251115 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "sqr_last_error",
                table: "sgr_outbox_message",
                type: "varchar(2000)",
                maxLength: 2000,
                nullable: true,
                comment: "上次投递失败错误信息",
                oldClrType: typeof(string),
                oldType: "varchar(200)",
                oldMaxLength: 200,
                oldNullable: true,
                oldComment: "上次投递失败错误信息")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "sgr_sequence_counter",
                columns: table => new
                {
                    Category = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TimeKey = table.Column<string>(type: "varchar(16)", maxLength: 16, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CustomPrefix = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MaxValue = table.Column<int>(type: "int", nullable: false),
                    AllocatedMaxValue = table.Column<int>(type: "int", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    RowVersion = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sgr_sequence_counter", x => new { x.Category, x.TimeKey, x.CustomPrefix });
                })
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "sgr_sequence_counter");

            migrationBuilder.AlterColumn<string>(
                name: "sqr_last_error",
                table: "sgr_outbox_message",
                type: "varchar(200)",
                maxLength: 200,
                nullable: true,
                comment: "上次投递失败错误信息",
                oldClrType: typeof(string),
                oldType: "varchar(2000)",
                oldMaxLength: 2000,
                oldNullable: true,
                oldComment: "上次投递失败错误信息")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
